# Maintainer: Jan de Groot <jgc@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>
# Contributor: Pierre Schmitz <pierre@archlinux.de>

pkgname=apr
pkgver=1.7.3
pkgrel=1
pkgdesc='The Apache Portable Runtime'
arch=('x86_64')
url='https://apr.apache.org/'
depends=('util-linux')
makedepends=('python')
license=('APACHE')
source=(https://archive.apache.org/dist/apr/apr-$pkgver.tar.bz2{,.asc}
        fix_apr-config.patch
        fix-apr.pc.patch
        ship_find_apr.m4.patch
        omit_extra_libs.patch
        dont_override_external_buildflags)
sha256sums=('455e218c060c474f2c834816873f6ed69c0cf0e4cfee54282cc93e8e989ee59e'
            'SKIP'
            '572efb102d02bb3e85ff08eca6b2ea8ff7936ce5228da7a45c1e639faca36a5c'
            '12595d331b48be9e44bd843635eb4f0f500bd213e197a551a9d383a28a24641f'
            '315932ef6536fc0644c1efe770ceb3bb675c3c7103a7cbb2f02efd8be03eb752'
            '3d491d3af8fb5a75db4e085a17e5d8dcbe058bd256ef893ee779dc97fc9f8ad6'
            '5ac0bdc532479f6082d29115ac9d3ca24524fd8b97a556568755b88e5a68e3df')
validpgpkeys=('5B5181C2C0AB13E59DA3F7A3EC582EB639FF092C'  # Jeff Trawick
              'B1B96F45DFBDCCF974019235193F180AB55D9977' # Nick Kew <niq@apache.org>
              '65B2D44FE74BD5E3DE3AC3F082781DE46D5954FA' # "Eric Covener <covener@apache.org>"
              '120A8667241AEDD4A78B46104C042818311A3DE5') # Ruediger Pluem <rpluem@apache.org>

prepare() {
  cd apr-$pkgver
  patch -Np1 -i ../fix_apr-config.patch
  patch -Np1 -i ../ship_find_apr.m4.patch
  patch -Np1 -i ../fix-apr.pc.patch
  patch -Np1 -i ../omit_extra_libs.patch
  patch -Np1 -i ../dont_override_external_buildflags
  #./buildconf
}

build() {
  cd apr-$pkgver
  ./configure --prefix=/usr --includedir=/usr/include/apr-1 \
    --with-installbuilddir=/usr/share/apr-1/build \
    --enable-nonportable-atomics \
    --with-devrandom=/dev/urandom --disable-static
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  cd apr-$pkgver
  make -j1 check
}

package() {
  cd apr-$pkgver
  make DESTDIR="$pkgdir" install
}
